package com.silence.ByteDance;

// 找出最长的神奇数列
public class easy_97 {
    public static String solution(String inp) {
        // Edit your code here
        int i = 0;
        int j = 1;
        int max_i = 0;
        int max_j = 1;
        char[] chars = inp.toCharArray();
        for (int k = 0; k < chars.length - 1; k++) {
            if (chars[k] != chars[k + 1]) {
                j += 1;
            } else {
                if (j > max_j) {
                    max_j = j;
                    max_i = i;
                }
                i = k;
                j = 1;
            }
        }
        String res = "";
        for (int k = max_i; k <max_i+max_j; k++) {
            res += String.valueOf(chars[k]);
        }
        return res;
    }

    public static void main(String[] args) {
        // Add your test cases here
        System.out.println(solution("0101011101").equals("010101"));
    }
}
